package servletClasses;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import daoClasses.InsertIUDao;

import beanClasses.IndividualUser;
import beanUtils.BeanUtilClass;

/**
 * Servlet implementation class IUServlet
 */
@WebServlet("/IUServlet")
public class IUServlet extends HttpServlet 
{
	private static final long serialVersionUID = 1L;

    public IUServlet() {
        super();
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		doPost(request,response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("IN IU SErvlet");
		IndividualUser iu=new IndividualUser();
		InsertIUDao id=new InsertIUDao();
		BeanUtilClass.populateBean(iu, request);
		String result=id.InsertIndividualUser(iu);
		if(result.equals("SUCESS"))
		{
			request.getRequestDispatcher("/IURegistration.jsp").forward(request, response);
		}
		else
		{
			request.getRequestDispatcher("/IURegistration.jsp").forward(request, response);
		}
	}
}
